/**
 * Created by Administrator on 2017/12/6 0006.
 */
var mainApp={
    //拼接链接参数
    toQueryPair : function (key, value) {
        if (typeof value == 'undefined') {
            return key
        }
        return key + '=' + encodeURIComponent(value === null ? '' : String(value))
    },
    //处理链接参数
    toQueryString : function (obj) {
        var ret = [];
        for (var key in obj) {
            key = encodeURIComponent(key);
            var values = obj[key];
            if (values && values.constructor == Array) {
                var queryValues = [];
                for (var i = 0, len = values.length, value; i < len; i++) {
                    value = values[i];
                    queryValues.push(mainApp.toQueryPair(key, value))
                }
                ret = ret.concat(queryValues)
            } else {
                ret.push(mainApp.toQueryPair(key, values))
            }
        }
        return ret.join('&')
    },
    //生成链接
    getUrl : function (routes, params, full) {
        var baseUrl = app_routes ? app_routes : './index.php?i=2&c=entry&m=mx_shop&do=mobile&r=ROUTES';
        routes = routes.replace(/\//ig, ".");
        var url = baseUrl.replace('ROUTES', routes);
        if (params) {
            if (typeof(params) == 'object') {
                url += "&" + mainApp.toQueryString(params)
            } else if (typeof(params) == 'string') {
                url += "&" + params
            }
        }
        return url;
    },
    //验证手机号
    isPhone:function(num){
        var pattern = /0?(13|14|15|17|18|19)[0-9]{9}/;
        if(pattern.test(num)){
            return true;
        }
        return false;
    },

};/**
 * Created by Administrator on 2017/12/25 0025.
 */
